//
//  SurroundViewController.m
//  wAudioShare
//
//  Created by 赵帅 on 14-1-11.
//  Copyright (c) 2014年 赵帅. All rights reserved.
//

#import "SurroundViewController.h"
#import "SurGroupViewController.h"
#import "SurMusicSelectViewController.h"
#import "SurDataShareObj.h"

@interface SurroundViewController ()

@end

@implementation SurroundViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [[SurDataShareObj sharedInstance] listen];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navigation methods
-(NSString *)navigationBarTitle
{
    return @"Surrounder";
}


#pragma mark -
#pragma mark UITableView Delegate & Datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    }
    else
    {
        for(UIView * subview in [cell.contentView subviews])
        {
            [subview removeFromSuperview];
        }
    }
    
    // Configure the cell.
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    if(indexPath.row == 0)
    {
        cell.textLabel.text = @"预设Surrounder组";
    }
    else if(indexPath.row == 1)
    {
        cell.textLabel.text = @"选择音乐播放到多个音箱";
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
    
    if(indexPath.row == 0)
    {
        SurGroupViewController * controller = [[SurGroupViewController alloc] initWithNibName:@"SurGroupViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
    else if(indexPath.row == 1)
    {
        SurMusicSelectViewController * controller = [[SurMusicSelectViewController alloc] initWithNibName:@"SurMusicSelectViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
}

@end
